#e
#Title[uƖ̋ԁv]
#Text[Փx:Normal

邾ȁ[Ċ̎ԑ
^teBAƂ͊֌W܂]
#BGM[.\..\..\bgm\bgm.wav]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{
	
	@Initialize{
		InitializeData();
		InitializeAction();
		
		SetLife(10);
		
		SetX( GetCenterX() );
		SetY( GetCenterY() );
		
		SetDurableSpellCard();
		SetEnemyMarker(false);
		
		TMain();
	}
	
	@MainLoop{
		yield;
	}
	
	@DrawLoop{
		DrawBoss(imgBoss_Yukari);
	}
	
	@Finalize{
		FinalizeData();
	}
	
	task TMain(){
		Wait(60);
		
		DeclareSpell();
		
		AlphaSet();
		Atack();
	}
	
	function DeclareSpell(){
		SetAction(ACT_SPELL,180);
		CutIn(KOUMA,"uƖ̋ԁv",imgCutin_Yukari,0,0,256,320);
		SetScore(260000);
		SetTimer(70);
		SetEnemyMarker(false);
		Wait(180);
	}
	
	task Atack(){
		let sx = GetClipMinX();
		let sy = 130 + rand(-50,50);
		let ex = GetClipMaxX();
		let ey = 130 + rand(-50,50);
		let rl = -1;
		let waitspan = 600;
		
		Twilight(sx,sy,ex,ey,1);
		
		loop{
			Wait(waitspan);
			
			if( rl == 1 ){
				sx = GetClipMinX();
				sy = rand( GetClipMinY(),GetClipMaxY() );
				ex = GetClipMaxX();
				ey = rand( GetClipMinY(),GetClipMaxY() );
			}else{
				sx = rand( GetClipMinX(),GetClipMaxX() );
				sy = GetClipMinY();
				ex = rand( GetClipMinX(),GetClipMaxX() );
				ey = GetClipMaxY();
			}
			
			rl *= -1;
			
			waitspan -= 35;
			
			Twilight( sx,sy,ex,ey,[-1,1][rand_int(0,1)] );
		}
	}
	
	task Twilight(sx,sy,ex,ey,ndflag){
		let mspeed = 60;
		
		let vx = sx;
		let vy = sy;
		
		let angle = GetGapAngle(sx,sy,ex,ey);
		let leng = GetGapLength(sx,sy,ex,ey);
		
		let mx = mspeed * cos(angle);
		let my = mspeed * sin(angle);
		
		let shotnum = truncate(leng / mspeed) + 2;
		
		let obj = CreateObjLaserB( sx,sy,0,angle,192,0,leng,4,false);
		Obj_SetCollisionToPlayer(obj,false);
		ObjShot_SetBombResist(obj,true);
		
		Wait(60);
		
		Concentration01(120);
		PlaySE(se2);
		Wait(120);
		
		loop(shotnum){
			ShotTask(vx,vy,angle + 90 *  ndflag,55);
			ShotTask(vx,vy,angle + 90 * -ndflag,56);
			
			vx += mx;
			vy += my;
		}
		
		loop(16){
			PlaySE(seshot3);
			
			Wait(15);
		}
		
		if( !Obj_BeDeleted(obj) ){
			Obj_Delete(obj);
		}
	}
	
	task ShotTask(x,y,angle,graph){
		let speed = 0.13;
		let pspeed = 0.13;
		let pspeed2 = 0;
		let pspeed3 = 0.11;
		
		loop(16){
			CreateShot01(x,y,speed,angle,graph,0);
			
			speed += pspeed + pspeed2;
			pspeed2 += pspeed3;
			
			Wait(15);
		}
	}
	
	task AlphaSet(){
		let alpha = 255;
		
		loop(120){
			SetAlpha(alpha);
			
			alpha -= 191 / 120;
			
			yield;
		}
	}
	
	#include_function ".\..\..\initialize_boss.txt"
	#include_function ".\..\..\lib\lib_anime_yukari.txt"
	
	#include_function ".\..\..\lib\lib_value.txt"
	#include_function ".\..\..\lib\lib_obj.txt"
}